#-*- codeing = utf-8 -*-
#@Time : 2020/8/8 17:55
#@Author : 阳某
#@File : 直播练习.py
#@Software : PyCharm
from selenium import webdriver
from time import  sleep
driver = webdriver.Chrome()
url = 'https://www.huya.com/g/lol'
driver.get(url)
num =1
while True:
    print('第'+str(num)+'页------------------------')
    num+=1
    sleep(3)
    html = driver.page_source
    # print(html)
    # 用selenium的解析方法会出现报错，就是页面还没来得及加载出来，你就去解析，所以页面解析一般用第三方库
    names = driver.find_elements_by_xpath('//i[@class="nick"]')
    counts = driver.find_elements_by_xpath('//i[@class="js-num"]')
    # for name , count in zip(names,counts):
    #     # print(name,":",count)
    #     print(name.text,":",count.text)
    if html.find("laypage_next")!=-1:
        # 必须操作他的元素时就用
        driver.find_element_by_xpath('//a[@class="laypage_next"]').click()
    else:
        break







